home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1421 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.1 KB  |  51 lines

  1. Path: news.voicenet.com!news
  2. From: David Zuckman <dzuckman@omni.voicenet.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Quick, easy question on externs...
  5. Date: Wed, 10 Jan 1996 16:44:28 -0500
  6. Organization: Voicenet - Internet Access - (215)674-9290
  7. Message-ID: <30F4333C.41A9@omni.voicenet.com>
  8. NNTP-Posting-Host: ivyland38.voicenet.com
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0b4 (WinNT; I)
  13.  
  14. I got two source files:
  15.  
  16. z1.cpp
  17. ======
  18.     #include <iostream.h>
  19.  
  20.     extern int const x;
  21.  
  22.     void main( void ) {
  23.         x;
  24.     }
  25.  
  26. z2.cpp
  27. ======
  28.     int const x = 5;
  29.  
  30. They compile and link fine (I'm using MS Visual C++ 2.1).
  31.  
  32. I change the line in z1.cpp that reads
  33.         x;
  34. to
  35.         cout << x;
  36. and I get
  37.  
  38.     Incrementally linking...
  39.     LINK : performing full link
  40.     z1.obj : error LNK2001: unresolved external symbol "?x@@3HB (int const  x)"
  41.     WinDebug/dbx.exe : error LNK1120: 1 unresolved externals
  42.  
  43. What gives?
  44.  
  45. Please mailto:dzuckman@omni.voicenet.com
  46.  
  47. ]:8)  David A. Zuckman
  48. =======================================================================
  49. How to ride:  Sit on horse.  Listen to your instincts.  Do the opposite
  50. of what they say.
  51.